home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 281 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: kuhub.cc.ukans.edu!anh
  2. From: anh@kuhub.cc.ukans.edu
  3. Newsgroups: comp.lang.c
  4. Subject: ugly constants and header files
  5. Message-ID: <1996Jan3.155754.111142@kuhub.cc.ukans.edu>
  6. Date: 3 Jan 96 15:57:54 CST
  7. Organization: University of Kansas Academic Computing Services
  8.  
  9. Hello,
  10.  
  11. I have a list of constants, some defined using #define, some are string 
  12. constants a la char *gSuperStrings[]={"aa","bb"};
  13.  
  14. These constants are used by multiple modules which are linked together to 
  15. a program. However, I have more than one program using these constants,
  16. hence I put the constants in a header file. I know it is ugly to put
  17. definitions in a header file.
  18.  
  19. My current solution is to change all the #define to integer constants and 
  20. to keep 2 files:
  21.  
  22. my_const.h        --- To be included only once (perferably by the main() 
  23.               module). Definitions
  24.  
  25. my_ext.h          --- To be included by any modules using the constants.
  26.                       Declarations.
  27.  
  28. Is this the best solution? Are there any other way?
  29.  
  30. Thank-you,
  31. Anh
  32.